package com.lions.client.view.basepanel;

import java.util.ArrayList;
import java.util.Collections;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.StackLayoutPanel;
import com.lions.client.controller.Controller;
import com.lions.client.model.Model;
import com.lions.client.view.mappanel.MapPanel;

/**
 * 
 *
 *
 */
public class BasePanel extends StackLayoutPanel {

	/**
	 * Default constructor takes a reference to the module list (Model) and a
	 * reference to the button panel (Controller)
	 */
	public BasePanel(final Model m, final Controller c, final MapPanel map) {
		super(Unit.EM);

		model = m;
		control = c;
		mapPanel = map;
		setStyleName("splitlayoutstyle");
		configList = new ArrayList<ConfigurationsPanel>();

	}

	public void populate() {
		clear();
		configList.clear();
		if (model.checkMin()) {

			config1 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base1.jpg", 0, 0, 1, 0, 0, 1, -1, 1, 0, 2, 1, -1,
					0, -1, 2, 0, -1, 0, 1, 1);
			config2 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base2.jpg", 0, 0, 0, 1, 1, 1, 1, 2, 2, 1, -1, 0,
					-1, 1, 0, -1, 0, 2, 1, 0);
			config3 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base3.jpg", 0, 0, -1, 0, 0, -1, 1, -1, 0, -2, -1,
					1, 0, 1, -2, 0, 1, 0, -1, -1);
			config4 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base4.jpg", 0, 0, -1, 0, 0, 1, -1, -1, -2, 0, 1, 1,
					1, 0, 0, 2, 0, -1, -1, 1);
			config5 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base5.jpg", 0, 0, -1, 0, 1, 0, 1, 1, 1, -1, 0, 1,
					-1, 1, -1, -1, -2, 0, 2, 0);
			config6 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base6.jpg", 0, 0, 0, -1, 0, 1, 1, -1, -1, -1, 1, 0,
					1, 1, -1, 1, 0, 2, 0, -2);
			config7 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base7.jpg", 0, 0, -1, 0, 1, 0, -1, -1, -1, 1, 0,
					-1, 1, -1, 1, 1, 2, 0, -2, 0);
			config8 = new ConfigurationsPanel(model, control, mapPanel,
					"images/base8.jpg", 0, 0, 0, -1, 0, 1, -1, 1, 1, 1, -1, 0,
					-1, -1, 1, -1, 0, -2, 0, 2);

			configList.add(config1);
			configList.add(config2);
			configList.add(config3);
			configList.add(config4);
			configList.add(config5);
			configList.add(config6);
			configList.add(config7);
			configList.add(config8);
			Collections.sort(configList);
			for (ConfigurationsPanel config : configList) {
				this.add(config,
						"Total Movements = " + config.getMovementPoints(), 1.8);
			}
		}

	}

	private ConfigurationsPanel config1;
	private ConfigurationsPanel config2;
	private ConfigurationsPanel config3;
	private ConfigurationsPanel config4;
	private ConfigurationsPanel config5;
	private ConfigurationsPanel config6;
	private ConfigurationsPanel config7;
	private ConfigurationsPanel config8;
	private Model model;
	private Controller control;
	private MapPanel mapPanel;
	private ArrayList<ConfigurationsPanel> configList;
}
